<template>
  <div class="header">
      <div class="menus">
        <div class="item" :class="[currentIndex == index ? 'line' : '']" v-for="(item, index) in menus" @click="menuHandel(index)">
          <div class="label" :class="[currentIndex == index ? 'active' : '']">{{item.name}}</div>
        </div>
      </div>
    <div class="right">
      <div @click="toUserInfo">个人中心</div>
      <div @click="handleLogout">退出</div>
    </div>
  </div>
</template>
<script setup>
  import { ref, defineProps } from 'vue'
  import {useRouter} from 'vue-router'
  import { useLogout } from '/@/components/hzsystem/LoginPublicFuncation';

  const { handleLogout } = useLogout()
  const props = defineProps({
      menus: {
          type: Array,
          default: () => []
      }
  })
  const currentIndex = ref(0)
  const router = useRouter()
  const menuHandel = index => {
    currentIndex.value = index;
    router.push({path: props.menus[index].path})
  }

  const toUserInfo = () => {
    router.push({name: 'UserInfo'})
  }
</script>
<style scoped lang="scss">
.header{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  height: 50px;
  padding: 0 8px;
  background-color: rgb(30, 45, 112);
  display: flex;
  align-items: center;
  justify-content: space-between;

  .menus{
    height: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    .item{
      position: relative;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 0 10px;
      cursor: pointer;
      .label{
        padding: 0 14px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        color: rgb(255, 255, 255);
        text-decoration: none;
        font-size: 14px;
      }
      .active{
        color: aqua;
        border-radius: 10px;
        box-shadow: inset 3px 3px 4px rgb(0, 0, 0), 1.5px 2px 2px rgba(255, 255, 255, 0.1);
      }

    }
    .line{
      &:before{
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 999;
        height: 3px;
        background: rgb(66, 104, 207);;
      }
    }
  }

  .right{
    display: flex;
    align-items: center;
    div{
      margin-left: 14px;
      font-size: 14px;
      cursor: pointer;
      color:#fff;
      &:hover{
        color: aqua;
      }
    }
  }


}

</style>